﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Northwind.Objects
{
    public class Employee
    {
        public int EmployeeID { get; set; }
        public string LastName { get; set; }
        public string FirstName { get; set; }
        public string Title { get; set; }
        public string TitleOfCourtesy { get; set; }
        public DateTime? BirthDate { get; set; }
        public DateTime? HireDate { get; set; }
        public string Address { get; set; }
        public string City { get; set; }
        public string Region { get; set; }
        public string PostalCode { get; set; }
        public string Country { get; set; }
        public string HomePhone { get; set; }
        public string Extension { get; set; }
        public string Notes { get; set; }
        public string PhotoPath { get; set; }

        #region Constructor
        public Employee()
        {
        }

        public Employee(string sText)
        {
            try
            {
                if (!string.IsNullOrEmpty(sText))
                {
                    string[] M = sText.Split(new char[] { ',' }, StringSplitOptions.None);
                    int iTemp;
                    if(int.TryParse(M[0], out iTemp))
                    {
                        EmployeeID = iTemp;
                    }
                    LastName = M[1];
                    FirstName = M[2];
                    Title = M[3];
                    TitleOfCourtesy = M[4];
                    DateTime dtTemp;
                    if (DateTime.TryParse(M[5], out dtTemp))
                    {
                        BirthDate = dtTemp;
                    }
                    if (DateTime.TryParse(M[6], out dtTemp))
                    {
                        HireDate = dtTemp;
                    }
                    Address = M[7];
                    City = M[8];
                    Region = M[9];
                    PostalCode = M[10];
                    Country = M[11];
                    HomePhone = M[12];
                    Extension = M[13];
                    Notes = M[14];
                    PhotoPath = M[15];
                }
            }
            catch (Exception ex)
            {
            }
        }
        #endregion Constructor End
    }

    public class Territory
    {
        public string TerritoryDescription { get; set; }
        public Region Region { get; set; }
    }

    public class Region
    {
        public string RegionDescription { get; set; }
    }
}
